//
//  SearchPersonViewController.m
//  Findif
//
//  Created by Mac on 2019/3/16.
//  Copyright © 2019年 Cicel Chen. All rights reserved.
//

#import "SearchPersonViewController.h"
#import "MyFansTableViewCell.h"
#import "PersonalViewController.h"

@interface SearchPersonViewController ()<UITextFieldDelegate,UITableViewDelegate,UITableViewDataSource,MyFansTableViewCellDelegate>

@property (nonatomic, weak)UITableView * tableView;
//@property (nonatomic, weak)UITextField * searchTextfiled;


@end

@implementation SearchPersonViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.view.backgroundColor = ColorWithRGB(0xEFF0F1);
    self.title = @"搜索结果";

    [self setupUI];
}



- (void)setupUI{
    
//    UITextField * searchTextfiled = [[UITextField alloc] initWithFrame:CGRectMake(0, 5 * SCREENH6, 260 * SCREENH6, 30 * SCREENH6)];
//
//    searchTextfiled.borderStyle = UITextBorderStyleRoundedRect;
//    searchTextfiled.backgroundColor = [UIColor whiteColor];
//    //设置光标颜色
//    searchTextfiled.tintColor = [UIColor whiteColor];
//    //修改占位符文字颜色
//    NSMutableDictionary *attrs = [NSMutableDictionary dictionary];
//    attrs[NSForegroundColorAttributeName] = ColorWithRGB(0xbebebe);
//    attrs[NSFontAttributeName] = [UIFont fontWithName:@"PingFangSC-Regular" size:15 * SCREENH6];
//    searchTextfiled.attributedPlaceholder = [[NSAttributedString alloc] initWithString:self.string attributes:attrs];
//    searchTextfiled.textColor = [UIColor blackColor];
//    searchTextfiled.leftView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 22 * SCREENH6, 0)];
//    //设置显示模式为永远显示(默认不显示)
//    searchTextfiled.leftViewMode = UITextFieldViewModeAlways;
//    searchTextfiled.font = [UIFont fontWithName:@"PingFangSC-Regular" size:15 * SCREENH6];
//    UIView * rightView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 35 * SCREENH6, 20 * SCREENH6)];
//    UIImageView *image=[[UIImageView alloc] initWithFrame:CGRectMake(5, 0, 16 * SCREENH6, 17.5 * SCREENH6)];//WithImage:[UIImage imageNamed:@"手机号"]];
//    image.image = [UIImage imageNamed:@"hg"];
//    [rightView addSubview:image];
//    searchTextfiled.leftView = rightView;
//    searchTextfiled.leftViewMode = UITextFieldViewModeAlways;
//    searchTextfiled.returnKeyType = UIReturnKeySearch;
//    searchTextfiled.delegate = self;
//
//    self.searchTextfiled = searchTextfiled;
//
//    //    [view addSubview:self.searchTextfiled];
//
//    self.navigationItem.titleView = self.searchTextfiled;
    
    
    
    UITableView * tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, kScreenW, kScreenH) style:UITableViewStylePlain];
    tableView.delegate = self;
    tableView.dataSource = self;
    tableView.backgroundColor = ColorWithRGB(0xEFF0F1);
    tableView.rowHeight = 60 * SCREENH6;
    tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    tableView.showsVerticalScrollIndicator = NO;
    //    tableView.hidden = YES;
    
    self.tableView = tableView;
    
    [self.tableView registerClass:[MyFansTableViewCell class] forCellReuseIdentifier:@"SearchPersonTableViewCell"];
    
    //    self.messageTableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
    //
    //        [self updateData];
    //    }];
    
    [self.view addSubview:self.tableView];
    
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
    return 1;
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    
    return self.modelArray.count;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    
    MyFansTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SearchPersonTableViewCell" forIndexPath:indexPath];
    
    cell.searchModel = self.modelArray[indexPath.row];
    
    return cell;
    
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    SearchPersonModel * model = self.modelArray[indexPath.row];
    
    NSString * ID = [NSString stringWithFormat:@"%@",model.id];
    
    PersonalViewController * personVC = [PersonalViewController new];
    
    personVC.ID = ID;
    
    [self.navigationController pushViewController:personVC animated:YES];
}

@end
